﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using RBAC_Set.API.Application.Commands;

namespace RBAC_Set.API.Controllers
{
    /// <summary>
    /// RBAC控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RBACController : ControllerBase
    {
        public IMediator mediator { get; set; }
        public RBACController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 权限的添加
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<THE_WIND_RISES.Common.Dtos.Result> AddPermissionData(AddPermissionCommand cmd)
        {
            Console.WriteLine("权限添加");
            var res = await mediator.Send(cmd);
            return res;
        }
        /// <summary>
        /// 添加角色信息
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<THE_WIND_RISES.Common.Dtos.Result> AddRoleData(AddRoleCommand cmd)
        {
            var res = await mediator.Send(cmd);
            return res;
        }
        /// <summary>
        /// 添加用户信息  及其  用户角色关联信息
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<THE_WIND_RISES.Common.Dtos.Result> AddUsersData(AddUsersCommand cmd)
        {
            var res = await mediator.Send(cmd);
            return res;
        }
    }
}
